const mysql=require('mysql');

//创建数据库连接池
//1.连接(client)
//creatConnection（哪台服务器，用户名，密码，库）
const db=mysql.createPool({
    host:'localhost',
    user:'root',
    password:'yexuan0628',
    database:'node_js'
});
//console.log(db);

//2.查询
//query(干啥，回调)
db.query("select * from users;",(err,data)=>{
    if(err)
        console.log("出错了",err);
    else{
        console.log("成功了");
        console.log(data);
        console.log(JSON.stringify(data));
    }
});
